package view.macrogui
{
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	/**
	 */
	public class GoldChangeSprite extends TextField implements Updatable
	{
		private const POSITIVE_FORMAT:TextFormat = new TextFormat("Helvetica", 12, 0x00AF00);
		private const NEGATIVE_FORMAT:TextFormat = new TextFormat("Helvetica", 12, 0xEE0000);
		
		public function GoldChangeSprite(amount:int, x:Number = 20, y:Number = 30)
		{
			defaultTextFormat = (amount >= 0) ? POSITIVE_FORMAT : NEGATIVE_FORMAT;
			
			text = "" + amount;
			this.x = x;
			this.y = y;
		}
		
		public function update():void
		{
			if (!readyToRemove())
			{
				y++;
				alpha -= 0.01;
			}
		}
		
		public function readyToRemove():Boolean
		{
			return (alpha <= 0);
		}
	
	}

}